
package org.orcas.commons.collections.util;

import java.util.Collection;

import org.orcas.commons.collections.bag.HashBag;
import org.orcas.commons.collections.list.TreeList;
import org.orcas.commons.collections.set.HashSet;
import org.orcas.commons.collections.set.LinkedHashSet;

@SuppressWarnings("unchecked")
public class CollectionFactory {

	public static CollectionFactory INSTANCE = new CollectionFactory();

	private CollectionFactory(){
		
	}

	public Collection createCollection(CollectionKind kind) {
		switch (kind) {
			case SET:
				return new HashSet();
			case SEQUENCE:
				return new TreeList();
			case ORDERED_SET:
				return new LinkedHashSet();
			case BAG:
				return new HashBag();
			default: {
				throw new RuntimeException("Invalid arg to create a collection");
			}
		}
	}
	
	public Collection createCollection(CollectionKind kind, Collection c) {
		switch (kind) {
			case SET:
				return new HashSet(c);
			case SEQUENCE:
				return new TreeList(c);
			case ORDERED_SET:
				return new LinkedHashSet(c);
			case BAG:
				return new HashBag(c);
			default: {
				throw new RuntimeException("Invalid arg to create a collection");
			}
		}
	}
}

